<template>
  <el-form ref="feedback" :model="feedback" label-width="80px">
    <el-form-item label="问题标题" class="width-500">
      <el-input v-model="feedback.title" placeholder="请输入问题标题" size="small"></el-input>
    </el-form-item>
    <el-form-item label="问题详情" class="width-500">
      <el-input type="textarea" :autosize="{ minRows: 8, maxRows: 12}" placeholder="请输入问题详情" v-model="feedback.content" size="small"></el-input>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="postSubmit" size="small">提交</el-button>
    </el-form-item>
  </el-form>
</template>

<script>
export default {
  data () {
    return {
      feedback: {
        title: '',
        role: 'doctor',
        content: ''
      }
    }
  },
  methods: {
    postSubmit() {
      if(this.feedback.title == ''){
        this.$message({
          message: '问题标题不能为空!',
          type: 'error'
        });
        return;
      }

      let id = this.$store.state.doctorInfo.id;

      this.axios.post('/feedback/add',{
        title: this.feedback.title,
        userId: id,
        role: this.feedback.role,
        content: this.feedback.content
      }).then((response) => {
        if(response.data.code == 200){
          this.$message({
            message: response.data.msg,
            type: 'success'
          });
          return;
        }else{
          this.$message({
            message: response.data.msg,
            type: 'error'
          });
          return;
        }
      });
    }
  }
}
</script>
